<?php $Search = Dracosys::getSessionValue(SESSION_INTERFACE, 'SearchResult'); ?>
<h2>Resultado da Busca</h2>
<section id="Result">
    <section id="Result_Dados" class="section-update">
        <?php if(!empty($Search)): ?>
            <table id="Result_called" class="list">
                <thead>
                    <tr>
                        <th>Prioridade</th>
                        <th>Título</th>
                        <th>Responsável</th>
                        <th>Setor</th>
                        <th>Cliente</th>
                        <th>Tipo de Chamado</th>
                        <th>Data de Abertura</th>
                        <th>Data de Fechamento</th>
                        <th>Visualizar</th>
                    </tr>
                </thead>
                <tfoot>
                </tfoot>
                <tbody>
                    <?php
                        foreach($Search as $Called):
                            $class = $Called->is2DaysWithoutAnswer() ? 'withoutAnswer' : '';
                    ?>
                        <tr id="Result_CalledRef<?=$Called->getIDChamado()?>" class="<?=$class?>">
                            <td>
                                <?php
                                    if( $Called->isPriority() ) {
                                        echo '<img src="'.DRA_VIEW_URL.'/images/priority.png" alt="Prioridade" />';
                                    }
                                ?>
                            </td>
                            <td><?=$Called->getStTitulo()?></td>
                            <td>
                                <?php
                                    if($Called->hasResponsible()):
                                        echo $Called->getFuncionario()->getArDadosUsuario('StNome');
                                    else:
                                        echo DRA_DEFAULT_USERNAME;
                                    endif;
                                ?>
                            </td>
                            <td><?=$Called->getSetor()->getStNome()?></td>
                            <td><?=( !$Called->isInternalCalled() ? $Called->getCliente()->getCustomerName() : $Called->getCliente()->getArDadosUsuario('StNome'))?></td>
                            <td><?=$Called->getEnTipoChamado()?></td>
                            <td><?=datetimeBDtoBR($Called->getDtCriacao())?></td>
                            <td><?=datetimeBDtoBR($Called->getDtFechamento())?></td>
                            <td><a href="<?=DRA_URL?>atendimento/visualizar-chamado/id/<?= $Called->getIDChamado() ?>"><img src="<?=DRA_VIEW_URL?>images/descricao.png" alt="Visualizar Chamado" title="Visualizar Chamado" /></a></td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        <?php else: ?>
            <div class="no-data">Nenhum Chamado foi encontrado</div>
        <?php endif; ?>
    </section>
</section>